﻿function setupScrape(searchResultsSelector, id) {
    var safeMessage = "<ul id='" + id + "'>"

    $(searchResultsSelector).each(function () {
        safeMessage += '<li>' + $(this).outerHTML() + '</li>';
    });

    safeMessage += "</ul>"
    $('body').append(safeMessage);
}

function appendSafeMessage(message, id) {
    var safeMessage = "<div id='" + id + "'>";
    safeMessage += message;
    safeMessage += "</div>";
    $('body').append(safeMessage);
}

// Handle windows errors and log them.
window.onerror = function () {
    appendSafeMessage("Oh my error", "PageError");
};

// Add a jQuery protype
jQuery.fn.outerHTML = function (s) {
    return (s)
? this.before(s).remove()
: jQuery("<p>").append(this.eq(0).clone()).html();
}